<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div ref="mydiv">111</div>
    <div id="box">
        <!-- 标签中的ref方法，拿到原生的节点 -->
        <input type="text" ref="mytext">

        <child ref="mychild"></child>
        <button @click="handleAdd">add</button>
    </div>

    <script type="text/javascript">
        Vue.component('child', {
            data(){
                return{
                    childname:"111111111"
                }
            },

            template:` 
                <div style="background:yellow;">child</div>
            `
        })

        new Vue ({
            el: '#box',
            methods:{
                handleAdd(){
                    console.log(this.$refs.mychild.childname)
                    // 输出结果拿到三个属性分别是：mydiv、mytext、mychild
                    // mydiv、mytext拿到DOM节点；mychild拿到组件对象
                }
            }
        })

    </script>
</body>
</html>